package org.example.util;

import cn.hutool.http.ContentType;
import cn.hutool.http.HttpConfig;
import cn.hutool.http.HttpRequest;
import org.apache.commons.lang.StringUtils;

import java.util.Map;

public class HttpUtils {

    public static void main(String[] args) {
        /*String url = "https://example.com/api/token";
        // 构建请求参数
        Map<String, Object> paramMap = new HashMap<>();
        paramMap.put("grant_type", "client_credentials");
        paramMap.put("client_id", "your_api_key");
        paramMap.put("client_secret", "your_secret_key");
        String result = postForm(url, paramMap);
        // 输出响应结果
        System.out.println(result);*/
        String id = "  ";
        if (StringUtils.isNotEmpty(id) || id.equals("0")) {
            System.out.println();
        }


    }

    public static String postForm (String url, Map<String, Object> paramMap) {
        // 替换为实际的请求 URL
        HttpConfig httpConfig = new HttpConfig()
                .setConnectionTimeout(1000)
                .setReadTimeout(1000)
                .setMaxRedirectCount(3);
        // 发送 POST 请求
        String result = HttpRequest.post(url)
                .form(paramMap)
                .contentType(ContentType.FORM_URLENCODED.toString())
                .setConfig(httpConfig)
                .execute()
                .body();
        return result;
    }

}
